//
//  ViewController.m
//  午分享 摇一摇
//
//  Created by dllo on 16/8/2.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "ViewController.h"
#import "MyView.h"

@interface ViewController ()

@property (nonatomic, strong) UIView *myView;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.myView = [[UIView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:self.myView];
    [self.myView becomeFirstResponder];
    
}

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
// 摇晃开始
    self.myView.backgroundColor = [UIColor redColor];
    
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
// 摇晃结束
    self.myView.backgroundColor = [UIColor greenColor];
}

- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
// 摇晃取消
    self.myView.backgroundColor = [UIColor blueColor];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
